import os
from dashscope import MultiModalConversation

DASHSCOPE_API_KEY="sk-50d04b217f9443fea985d3ba45240822"
local_path = "测试图.jpeg" #本地文件的绝对路径
image_path = f"file://{local_path}"
messages = [
    {
        "role": "user",
        'content': [{'image': image_path},
                    {'text': '这是什么？'}] #输入对话
    }
]
responses = MultiModalConversation.call(
    api_key=DASHSCOPE_API_KEY,
    model='qwen-vl-max-latest', #模型名称
    messages=messages,
    stream=True,
    incremental_output=True
    )
for response in responses:
    print(response["output"]["choices"][0]["message"].content[0]["text"],end='')
print('\n')

messages.append(response['output']['choices'][0]['message'])
user_msg = {"role": "user", 
            "content": [{"text": "写一首诗描述这个场景"}]} #输入对话
messages.append(user_msg)
responses = MultiModalConversation.call(
    api_key=DASHSCOPE_API_KEY,
    model='qwen-vl-max-latest', #模型名称
    messages=messages,
    stream=True,
    incremental_output=True
    )
for response in responses:
    print(response["output"]["choices"][0]["message"].content[0]["text"],end='')